package com.ybk.zs.common.utils;

import java.io.UnsupportedEncodingException;

/**
 * �ַ���������
 * Created by Administrator on 2016/8/30.
 */
public class StringUtils {

    public static boolean isBlank(String str) {
        int strLen;
        if (str == null || (strLen = str.length()) == 0) {
            return true;
        }
        for (int i = 0; i < strLen; i++) {
            if ((!Character.isWhitespace(str.charAt(i)))) {
                return false;
            }
        }
        return true;
    }

    public static String getShortUuid(){
        StringBuilder sb = new StringBuilder(String.valueOf(System.currentTimeMillis()));
        String suffix = String.valueOf((int)(Math.random()*1000));
        for(int i=suffix.length();i<3;i++){
            sb.append("0");
        }
        sb.append(suffix);
        return sb.toString();
    }

    public static String getUTF8CharsetString(String sourceStr){
        try {
            return new String(sourceStr.getBytes("gbk"),"utf-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return "";
    }
}
